const tokenName = 'hmnews-83'
const channelName = 'hm-news-channel-83'
const historyName = 'hmnews-search'
// 本地设置token
export function setToken (token) {
  localStorage.setItem(tokenName, JSON.stringify(token))
}
// 获取本地token
export function getToken () {
  return JSON.parse(localStorage.getItem(tokenName)) || []
}
// 移除本地token
export function removeToken () {
  localStorage.removeItem(tokenName)
}
// 本地设置频道列表
export function setChannelList (channelList) {
  localStorage.setItem(channelName, JSON.stringify(channelList))
}
// 获取本地频道列表
export function getChannelList () {
  return JSON.parse(localStorage.getItem(channelName))
}
// 保存搜索历史记录到本地
export function setHistory (list) {
  localStorage.setItem(historyName, JSON.stringify(list))
}
// 本地获取搜索历史记录
export function getHistory () {
  return JSON.parse(localStorage.getItem(historyName)) || []
}
